--[[
Name: oUF_cRefactored
Author: Sonora (The Dragonflight, US Kirin Tor)
Website & SVN: http://code.google.com/p/browniehelper/source/browse/#svn/trunk/oUF_cRefactored
License: GNU General Public License v3
]]

--Config runs in the cRefactored namespace for convenience
setfenv(1, cRefactored)

--Style options
styles = {

    --[[
    Useful as a default style to inherit, this style implements the oUF_Caellian
    look near r61 (a few minor differences, including the ColorThreat 
    implementation from r60)
    ]]--
    
    Caellian = {
        
        --General settings
        partyUnitStyleCutoff = 5,
        
        partyUnitStyleColLength = 1,
        raidUnitStyleColLength = 1,
        
        --Frame positions
        playerPosition = {'CENTER', UIParent, -278.5, -158},
        targetPosition = {'CENTER', UIParent, 278.5, -158},
        partyPosition = {'TOPLEFT', UIParent, 'TOPLEFT', 15, -15},
        raidPosition = {'TOPLEFT', UIParent, 'TOPLEFT', 15, -15},
    
        raidColOffset = 7.5,
        raidRowOffset = -7.5,
        partyRowOffset = -27.5,
     
         --Applied to all frames before unit-specific styles
        preStyle = {    
            setFrameLevel,
            style,
        },

        --Applied to all frames after unit-specific styles
        postStyle = {
            barFade,
        },
        
        --Unit frame styles
        unitStyles = {

            player = {
                largeFrameStyle,
                createBuffs(BUFFS, {'TOPRIGHT', nil, 'TOPLEFT', -9, 1}, LEFT, 24, 24*8, 24, nil, false),  
                createBuffs(DEBUFFS, {'TOPLEFT', nil, 'BOTTOMLEFT', -1, -7.5}, BOTTOM, 23*0.97, 230, 23*0.97, nil, false),    
                playerFrame, 
                leaderIcon, 
                masterLooterIcon,
                basedOnPlayerClass({
                    DEATHKNIGHT = runeBar,
                }),
                dots(
                    --Dot that replaces DebuffHighlight mod
                    {texture = [=[Interface\Addons\oUF_cRefactored\media\highlightTex]=],
                    blendMode = 'ADD',
                    missingColor = {0.15, 0.15, 0.15, 0.0},
                    anchor = 'Health',
                    setPoint = {{'TOPLEFT', nil, 'TOPLEFT'},{'BOTTOMRIGHT', nil, 'BOTTOMRIGHT'}},
                    handlerType = dotHandlerDebuffHighlight}
                ),
            },
            
            focus = {
                mediumFrameStyle, 
                infoText,
                dots(
                    --Dot that replaces DebuffHighlight mod
                    {texture = [=[Interface\Addons\oUF_cRefactored\media\highlightTex]=],
                    blendMode = 'ADD',
                    missingColor = {0.15, 0.15, 0.15, 0.0},
                    anchor = 'Health',
                    setPoint = {{'TOPLEFT', nil, 'TOPLEFT'},{'BOTTOMRIGHT', nil, 'BOTTOMRIGHT'}},
                    handlerType = dotHandlerDebuffHighlight}
                ),
            },
            
            target = {
                setDirection(REVERSE),
                largeFrameStyle,       
                infoText,       
                createBuffs(BUFFS, {'TOPLEFT', nil, 'TOPRIGHT', 9, 1}, RIGHT, 24, 24*8, 24, nil, false), 
                createBuffs(DEBUFFS, {'TOPLEFT', nil, 'BOTTOMLEFT', -1, -7.5}, BOTTOM, 23*0.97, 230, 23*0.97, nil, false),     
                targetFrame},
            
            targettarget = {setDirection(REVERSE), mediumFrameStyle, infoText},
            focustarget = {setDirection(REVERSE), mediumFrameStyle, infoText},
            
            pet = {mediumFrameStyle, infoText, petFrame, range},

            unitPet = {miniFrameStyle, infoText},
            
            raidUnit = {
                smallFrameStyle,       
                infoText,       
                leaderIcon, 
                masterLooterIcon, 
                readyCheckIcon({'BOTTOMLEFT', 13, 1}), 
                range,
                dots(
                    --Dot that replaces DebuffHighlight mod
                    {texture = [=[Interface\Addons\oUF_cRefactored\media\highlightTex]=],
                    blendMode = 'ADD',
                    missingColor = {0.15, 0.15, 0.15, 0.0},
                    anchor = 'Health',
                    setPoint = {{'TOPLEFT', nil, 'TOPLEFT'},{'BOTTOMRIGHT', nil, 'BOTTOMRIGHT'}},
                    handlerType = dotHandlerDebuffHighlight}
                ),
            },
            
            partyUnit = {
                mediumFrameStyle,      
                infoText,       
                leaderIcon, 
                masterLooterIcon, 
                readyCheckIcon({'TOPRIGHT', 7, 7}),
                dots(
                    --Dot that replaces DebuffHighlight mod
                    {texture = [=[Interface\Addons\oUF_cRefactored\media\highlightTex]=],
                    blendMode = 'ADD',
                    missingColor = {0.15, 0.15, 0.15, 0.0},
                    anchor = 'Health',
                    setPoint = {{'TOPLEFT', nil, 'TOPLEFT'},{'BOTTOMRIGHT', nil, 'BOTTOMRIGHT'}},
                    handlerType = dotHandlerDebuffHighlight}
                ),
            }
        }
    },

    --[[
    My unit frame tweaks and extensions
    ]]--
    
    Sonora = {

        --Inherit settings in the root and unitStyles from Caellian (note this argument is a string)
        inheritStyle = 'Caellian',

        --General settings
        partyUnitStyleCutoff = 25,
        --partyUnitStyleCutoff = 10,
        
        partyUnitStyleColLength = 4,
        raidUnitStyleColLength = 4,
        
        --Frame positions
        --playerPosition = {x=-150, y=485},
        --targetPosition = {x=150, y=485},
        playerPosition = {'CENTER', UIParent, -278.5, -300},
        targetPosition = {'CENTER', UIParent, 278.5, -300},
        partyPosition = {'CENTER', UIParent, -54, -250},
        raidPosition = {'TOPLEFT', UIParent, 'TOPLEFT', 15, -15},
     
        raidColOffset = 15,
        raidRowOffset = -7.5,
        partyFrameOffset = -30.5,
     
        --[[
        Base cRefactored dot/timer configuration.
    
        Any parameters defined in dots/timers themselves will override these
        defaults.]]
    
        dotsConfig = {
            texture = [=[Interface\Addons\oUF_cRefactored\media\bubbleTex]=],
            anchor = 'Health',
            height = 10,
            width = 10,
            presentColor = {0.33, 0.59, 0.33, 1.0}, 
            missingColor = {0.15, 0.15, 0.15, 0.5},
            onlyShowPlayer = false,            
        },
        
        timersConfig = {
            texture = [=[Interface\Addons\oUF_cRefactored\media\normTex]=],
            barColor = {0.33, 0.59, 0.33, 1.0},
            height = 5,
            anchor = 'Power',
            direction = HORIZONTAL,
            stackPosition = {{'TOPLEFT',nil,'BOTTOMLEFT',0,-2},{'TOPRIGHT',nil,'BOTTOMRIGHT',0,-1}},
            onlyShowPlayer = true,
            backdrop = {
                bgFile = [=[Interface\Tooltips\UI-Tooltip-Background]=],
                insets = {top = -1, left = -1, bottom = -1, right = -1},
            },
        },
     
        --Unit frame styles
        unitStyles = {  
            
            player = {
                largeFrameStyle,
                createBuffs(BUFFS, {'TOPRIGHT', nil, 'TOPLEFT', -9, 1}, LEFT, 24, 24*8, 24, nil, false),  
                createBuffs(DEBUFFS, {'TOPLEFT', nil, 'BOTTOMLEFT', -1, -4}, BOTTOM, 23*0.97, 230, 23*0.97, nil, false),    
                playerFrame, 
                leaderIcon, 
                masterLooterIcon,
                basedOnPlayerClass({
                    DEATHKNIGHT = runeBar,
                }),
                dots(
                    --Dot that replaces DebuffHighlight mod
                    {texture = [=[Interface\Addons\oUF_cRefactored\media\highlightTex]=],
                    blendMode = 'ADD',
                    missingColor = {0.15, 0.15, 0.15, 0.0},
                    anchor = 'Health',
                    setPoint = {{'TOPLEFT', nil, 'TOPLEFT'},{'BOTTOMRIGHT', nil, 'BOTTOMRIGHT'}},
                    handlerType = dotHandlerDebuffHighlight}
                ),
            },
            
            target = {
                setDirection(REVERSE),
                largeFrameStyle,       
                infoText,       
                createBuffs(BUFFS, {'TOPLEFT', nil, 'TOPRIGHT', 9, 1}, RIGHT, 24, 24*8, 24, nil, false), 
                createBuffs(DEBUFFS, {'TOPLEFT', nil, 'BOTTOMLEFT', -1, -6}, BOTTOM, 23*0.97, 230, 23*0.97, nil, false),     
                targetFrame,
                basedOnPlayerClass({
                    DRUID = {
                        timers(
                            {aura = 'Faerie Fire',
                                barColor = {0.96, 0.55, 0.73, 0.8},
                                setPoint = {{'TOPLEFT',nil,'BOTTOMLEFT',0,-6},{'TOPRIGHT',nil,'BOTTOMRIGHT',0,-6}},
                                adjustmentHook = adjustForDebuffCount},
                            {aura = 'Insect Swarm',
                                barColor = {0.78, 0.61, 0.43, 0.8}},
                            {aura = 'Moonfire',
                                barColor = {0.41, 0.8, 0.94, 0.8}},
                            {aura = 'Lifebloom',
                                barColor = {0.33, 0.80, 0.33, 1.0},
                                handlerType = timerHandlerLifebloom},
                            {aura = 'Rejuvenation',
                                barColor = {0.96, 0.55, 0.73, 0.8}},
                            {aura = 'Regrowth',
                                barColor = {0.31, 0.45, 0.63}}
                            --[[,{handlerType = timerHandlerEclipse,
                                barColor = {0.96, 0.55, 0.73, 1.0},
                                anchor = 'Debuffs'},]]
                        )
                    },
                    WARLOCK = {
                        timers(
                            {aura = 'Curse of the Elements',
                                barColor = {0.58, 0.51, 0.79, 0.8},
                                setPoint = {{'TOPLEFT',nil,'BOTTOMLEFT',0,-6},{'TOPRIGHT',nil,'BOTTOMRIGHT',0,-6}},
                                adjustmentHook = adjustForDebuffCount},
                            {aura = 'Curse of Agony',
                                barColor = {0.95, 0.85, 0.12, 0.8}},
                            {aura = 'Corruption',
                                barColor = {0.95, 0.28, 0.26, 0.8}},
                            {aura = 'Unstable Affliction',
                                barColor = {0.41, 0.8, 0.94, 0.8}},
                            {aura = 'Immolate',
                                barColor = {0.41, 0.8, 0.94, 0.8}},
                            {aura = 'Haunt',
                                barColor = {0.33, 0.80, 0.33, 0.8}},
                            {aura = 'Fear',
                                barColor = {0.31, 0.45, 0.63}}
                        )
                    },
                }),
            },
            
            raidUnit = {
                smallFrameStyle,       
                infoText,       
                leaderIcon, 
                masterLooterIcon,
                mainAssistIcon,
                mainTankIcon,
                readyCheckIcon({'BOTTOMLEFT', 13, 1}), 
                friendlyRange,
                dots(
                    --Dot that replaces DebuffHighlight mod
                    {texture = [=[Interface\Addons\oUF_cRefactored\media\highlightTex]=],
                    blendMode = 'ADD',
                    missingColor = {0.15, 0.15, 0.15, 0.0},
                    anchor = 'Health',
                    setPoint = {{'TOPLEFT', nil, 'TOPLEFT'},{'BOTTOMRIGHT', nil, 'BOTTOMRIGHT'}},
                    handlerType = dotHandlerDebuffHighlight}
                ),
            },
            
            partyUnit = {
                mediumFrameStyle,      
                infoText,       
                leaderIcon, 
                masterLooterIcon,
                mainAssistIcon,
                mainTankIcon,
                readyCheckIcon({'TOPRIGHT', 7, 7}),
                friendlyRange,
                dots(
                    --Dot that replaces DebuffHighlight mod
                    {texture = [=[Interface\Addons\oUF_cRefactored\media\highlightTex]=],
                    blendMode = 'ADD',
                    missingColor = {0.15, 0.15, 0.15, 0.0},
                    anchor = 'Health',
                    setPoint = {{'TOPLEFT', nil, 'TOPLEFT'},{'BOTTOMRIGHT', nil, 'BOTTOMRIGHT'}},
                    handlerType = dotHandlerDebuffHighlight}
                ),
                basedOnPlayerClass({
                    DRUID = {
                        dots(
                            {aura = {'Mark of the Wild', 'Gift of the Wild'},
                                presentColor = {0.96, 0.55, 0.73, 1.0},
                                setPoint = {'CENTER', nil, 'CENTER', 0, 0}},
                            {aura = 'Thorns',
                                presentColor = {0.78, 0.61, 0.43, 1.0},
                                advancePosition = {'TOPLEFT', nil, 'TOPRIGHT', 1, 0}},
                            {aura = 'Innervate',
                                presentColor = {0.41, 0.8, 0.94, 1.0},
                                advancePosition = {'TOPLEFT', nil, 'TOPRIGHT', 1, 0}},
			    --Tracks the presence of any HoT, not necessarily our own
                            {aura = 'Lifebloom',
                                setPoint = {'TOPLEFT', nil, 'TOPRIGHT', 1, 2},
                                presentColor = {0.33, 0.59, 0.33, 1.0},
                                missingColor = {0.15, 0.15, 0.15, 0.0}},
                            {aura = 'Rejuvenation',
                                advancePosition = {'TOPLEFT', nil, 'BOTTOMLEFT', 0, 2},
                                missingColor = {0.15, 0.15, 0.15, 0.0},
                                presentColor = {0.96, 0.55, 0.73, 0.8}},
                            {aura = 'Regrowth',
                                advancePosition = {'TOPLEFT', nil, 'BOTTOMLEFT', 0, 2},
                                missingColor = {0.15, 0.15, 0.15, 0.0},
                                presentColor = {0.31, 0.45, 0.63, 1.0}}
                        ),
                        timers(
                            {aura = 'Lifebloom',
                                height = 5,
                                setPoint = {{'TOPLEFT',nil,'BOTTOMLEFT',0,-4},{'TOPRIGHT',nil,'BOTTOMRIGHT',0,-4}},
                                barColor = {0.33, 0.95, 0.33, 1.0},
                                handlerType = timerHandlerLifebloom},
                            {aura = 'Rejuvenation',
                                height = 5,
                                barColor = {0.96, 0.55, 0.73, 1.0}},
                            {aura = 'Regrowth',
                                height = 5,
                                barColor = {0.31, 0.45, 0.63, 1.0}}
                        ),
                    },
                    WARLOCK = {
                        dots(
                            {aura = 'Soulstone Resurrection',
                                presentColor = {0.58, 0.51, 0.79, 1.0},
                                setPoint = {'CENTER', nil, 'CENTER', 0, 0}},
                            {aura = 'Blood Pact',
                                presentColor = {0.77, 0.12, 0.23, 1.0},
                                advancePosition = {'TOPLEFT', nil, 'TOPRIGHT', 1, 0}}
                        ),
                    },
                }),
            },
        }
    },
}

--Set the default style
setCurrentStyle(styles.Sonora)
